package edu.zut.cs.network.Experiment7;
import java.util.Scanner;
import org.apache.log4j.*;

public class CountLetters {
    private static Logger logger = Logger.getLogger(CountLetters.class);
    public static int countLetters(String s){
        int count = 0;
        for(int i = 0; i < s.length();i++) {
            char ch = s.charAt(i);
            if((ch >= 'a' && ch<= 'z') || (ch >= 'A' && ch <= 'Z')){
                count++;
            }
            /*if(Character.isLetter(ch)){
                count++;//计算字符的个数
            }*/
        }
        return count;
    }
    public static void main(String[] args) {
        logger.info("请输入一个字符串：");
        Scanner input = new Scanner(System.in);
        String str = input.nextLine();
        int sum = CountLetters.countLetters(str);
        logger.info("该字符串中字母的个数为："+sum);
    }
}